﻿cms.Edit = function () {

    function _showTabOverlays() {
        var divs = document.getElementsByTagName("div");
        for (var i = 0; i < divs.length; i++) {
            if (divs[i].className == "pnlTabOverlay") {
                divs[i].style.display = "block";
                if (divs[i].childNodes.length == 0) {
                    var progress = document.createElement("img");
                    progress.setAttribute("src", "Admin/img/progress.gif");
                    progress.setAttribute("class", "progress");
                    progress.style.position = "absolute";
                    divs[i].appendChild(progress);
                }
                var img = divs[i].childNodes[0];
                var top = parseInt((divs[i].offsetHeight - 32) / 2, 0);
                top = top < 0 ? 0 : top;
                top = top > 30 ? 30 : top;
                img.style.top = top + "px";
                img.style.left = parseInt((divs[i].offsetWidth - 32) / 2, 0) + "px";
            }
        }
    }

    function _hideTabOverlays() {
        var divs = document.getElementsByTagName("div");
        for (var i = 0; i < divs.length; i++) {
            if (divs[i].className == "pnlTabOverlay") {
                divs[i].style.display = "none";
            }
        }
    }

    function _getSelectedCheckboxValues(containerID) {
        var container = document.getElementById(containerID);
        if (!container)
            return "";
        var inputs = container.getElementsByTagName("input");
        var ids = "";
        for (var i = 0; i < inputs.length; i++) {
            if (inputs[i].type.toLowerCase() == "checkbox" && inputs[i].checked) {
                if (ids != "")
                    ids += ",";
                ids += inputs[i].value;
            }
        }
        return ids;
    }

    return {
        ShowTabOverlays: _showTabOverlays,
        HideTabOverlays: _hideTabOverlays,
        GetSelectedCheckboxValues: _getSelectedCheckboxValues
    }

} ();

